<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use app\common\model\Activity as ActivityModel;
use app\common\model\ActivityCategory;
use think\facade\View;

class Activity extends Controller
{
    protected function initialize()
    {
        $activity_categories = ActivityCategory::order('sorder')->all();
        View::share('activity_categories', $activity_categories);
    }
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $top = ActivityModel::top()->all();
        $recommend = ActivityModel::hot()->all();
        return view('activity/index', ['top' => $top, 'hot' => $recommend]);
    }

    public function lists(Request $request)
    {
        //dump($request->param());
        $data = ActivityModel::filter($request->param())->order('is_index_top', 'desc')->with('category.type')->paginate();
        //dump($data[6]->category->type);
        return view('activity/list', ['datas' => $data]);
    }

    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        //
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        //
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
